﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using BCNPCObject;

namespace bus_TienichNPC
{
    public class clsTrinhKy_bus
    {              
        public DataSet SelectTrinhKy(string strMadviqly, string TEN_BIEUBC)
        {
            try
            {
                cls_STTIN_TRINHKY_Controller controlTK = new cls_STTIN_TRINHKY_Controller();
                return controlTK.select_STTIN_TRINHKY(strMadviqly, TEN_BIEUBC);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        
        public bool SaveTrinhKy(DataSet ds)
        {
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    cls_STTIN_TRINHKY_Controller controlTK = new cls_STTIN_TRINHKY_Controller();
                    controlTK.pInfor.CHIEU_DAI = Decimal.Parse(row["CHIEU_DAI"].ToString());
                    controlTK.pInfor.CHIEU_RONG = Decimal.Parse(row["CHIEU_RONG"].ToString());
                    controlTK.pInfor.CO_CHU = Decimal.Parse(row["CO_CHU"].ToString());
                    controlTK.pInfor.FONT_CHU = row["FONT_CHU"].ToString();
                    controlTK.pInfor.KIEU_CHU = row["KIEU_CHU"].ToString();
                    controlTK.pInfor.NGAY_CAPNHAT = DateTime.Parse(row["NGAY_CAPNHAT"].ToString());
                    controlTK.pInfor.NOI_DUNG = row["NOI_DUNG"].ToString();
                    controlTK.pInfor.TEN_DOITUONG = row["TEN_DOITUONG"].ToString();
                    controlTK.pInfor.TOADO_DOC = Decimal.Parse(row["TOADO_DOC"].ToString());
                    controlTK.pInfor.TOADO_NGANG = Decimal.Parse(row["TOADO_NGANG"].ToString());
                    controlTK.pInfor.TEN_BIEUBC = row["TEN_BIEUBC"].ToString();
                    controlTK.pInfor.MA_DVIQLY = row["MA_DVIQLY"].ToString();
                    controlTK.pInfor.FORMULA_NAME = row["FORMULA_NAME"].ToString();
                    controlTK.pInfor.FIELD_NAME = row["FIELD_NAME"].ToString();
                    controlTK.update_STTIN_TRINHKY();
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
       
        public bool InsertTrinhKy(DataSet ds)
        {
            try
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {

                    cls_STTIN_TRINHKY_Controller controlTK = new cls_STTIN_TRINHKY_Controller();
                    controlTK.pInfor.CHIEU_DAI = Decimal.Parse(row["CHIEU_DAI"].ToString());
                    controlTK.pInfor.CHIEU_RONG = Decimal.Parse(row["CHIEU_RONG"].ToString());
                    controlTK.pInfor.CO_CHU = Decimal.Parse(row["CO_CHU"].ToString());
                    controlTK.pInfor.FONT_CHU = row["FONT_CHU"].ToString();
                    controlTK.pInfor.KIEU_CHU = row["KIEU_CHU"].ToString();
                    controlTK.pInfor.NGAY_CAPNHAT = DateTime.Parse(row["NGAY_CAPNHAT"].ToString());
                    controlTK.pInfor.NOI_DUNG = row["NOI_DUNG"].ToString();
                    controlTK.pInfor.TEN_DOITUONG = row["TEN_DOITUONG"].ToString();
                    controlTK.pInfor.TOADO_DOC = Decimal.Parse(row["TOADO_DOC"].ToString());
                    controlTK.pInfor.TOADO_NGANG = Decimal.Parse(row["TOADO_NGANG"].ToString());
                    controlTK.pInfor.TEN_BIEUBC = row["TEN_BIEUBC"].ToString();
                    controlTK.pInfor.MA_DVIQLY = row["MA_DVIQLY"].ToString();
                    controlTK.pInfor.FORMULA_NAME = row["FORMULA_NAME"].ToString();
                    controlTK.pInfor.FIELD_NAME = row["FIELD_NAME"].ToString();
                    controlTK.insert_STTIN_TRINHKY();
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
